package com.hspedu.newData.dmsxl.动态规划.基础;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-23 
 * @Version: 1.0
 */

public class LC746使用最小花费爬楼梯 {

    public int minCostClimbingStairs(int[] cost) {
        int[] dp = new int[cost.length+1];
        for (int i = 2; i < cost.length + 1; i++) {
            dp[i] = Math.min(dp[i-2] + cost[i-2],dp[i-1] + cost[i-1]);
        }
        return dp[cost.length];
    }

    @Test
    public void test() {
        // 测试代码
        int i = minCostClimbingStairs(new int[]{10, 15, 20});
        int j = minCostClimbingStairs(new int[]{1,100,1,1,1,100,1,1,100,1});
        System.out.println("=======");
    }
}
